package com.example.service;

import com.example.entity.Score;
import com.example.entity.UserProgress;
import com.example.mapper.UserProgressMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/*用户进度业务处理
 */
@Service
public class UserProgressService {

    @Resource
    private UserProgressMapper userProgressMapper;

    public void add(UserProgress userProgress) {
        userProgressMapper.insert(userProgress);
    }

    public void deleteById(Integer id) {
        userProgressMapper.deleteById(id);
    }

    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids){
            this.deleteById(id);
        }
    }

    public void updateById(UserProgress userProgress) {
        userProgressMapper.updateById(userProgress);
    }

    public UserProgress selectById(Integer id) {
        return userProgressMapper.selectById(id);
    }

    public List<UserProgress> selectAll(UserProgress userProgress) {
        return userProgressMapper.selectAll(userProgress);
    }

    public PageInfo<UserProgress> selectPage(UserProgress userProgress, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<UserProgress> userProgressList = userProgressMapper.selectAll(userProgress);
        return PageInfo.of(userProgressList);
    }
}
